//
//  MCSignContractHeaderView.m
//  TLYL
//
//  Created by MC on 2017/11/3.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCSignContractHeaderView.h"
#import "MCContractMgtTool.h"
@interface MCSignContractHeaderView ()

//我的日结契约：每天1.1%的日结
//用户名：工资代理3                                 当前日结：0
@property (nonatomic,strong) UILabel * DayWagesProportion ;
@property (nonatomic,strong) UILabel * UserName;
//@property (nonatomic,strong) UILabel * Wage;


@end

@implementation MCSignContractHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    
    self.backgroundColor = [UIColor clearColor];
    
    UIView *baseView = [[UIView alloc] init];
    [self addSubview:baseView];
    baseView.backgroundColor = [UIColor whiteColor];
    //    baseView.frame=CGRectMake(0, 15, G_SCREENWIDTH-26, 101);
    baseView.frame=CGRectMake(0, 15, G_SCREENWIDTH-26, 71);
    baseView.clipsToBounds=YES;
    baseView.layer.cornerRadius=6;
    
    
    _DayWagesProportion = [[UILabel alloc] init];
    _DayWagesProportion.font=[UIFont systemFontOfSize:12];
    _DayWagesProportion.textColor=RGB(46,46,46);
    _DayWagesProportion.textAlignment=NSTextAlignmentLeft;
    [baseView addSubview:self.DayWagesProportion];
    _DayWagesProportion.text = @"我的日结契约：加载中...";
    [_DayWagesProportion mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(baseView.mas_top).offset(10);
        make.left.equalTo(baseView.mas_left).offset(16);
        make.right.equalTo(baseView.mas_right).offset(-16);
        make.height.mas_equalTo(20);
    }];
    
    _UserName = [[UILabel alloc] init];
    [baseView addSubview:_UserName];
    _UserName.font=[UIFont systemFontOfSize:12];
    _UserName.textColor=RGB(46,46,46);
    _UserName.textAlignment=NSTextAlignmentLeft;
    _UserName.text = @"下级【加载中...】日结契约：0 ";
    [_UserName mas_makeConstraints:^(MASConstraintMaker *make) {
        //        make.bottom.equalTo(baseView.mas_bottom).offset(-40);
        make.bottom.equalTo(baseView.mas_bottom).offset(-10);
        make.left.equalTo(baseView.mas_left).offset(16);
        make.right.equalTo(baseView.mas_right).offset(-10);
        make.height.mas_equalTo(20);
    }];
    
    
    //    _Wage = [[UILabel alloc] init];
    //    [baseView addSubview:_Wage];
    //    _Wage.font=[UIFont systemFontOfSize:12];
    //    _Wage.textColor=RGB(46,46,46);
    //    _Wage.textAlignment=NSTextAlignmentLeft;
    //    _Wage.text = @"当前日结：0 ";
    //    [_Wage mas_makeConstraints:^(MASConstraintMaker *make) {
    //
    //        make.bottom.equalTo(baseView.mas_bottom).offset(-10);
    //        make.left.equalTo(baseView.mas_left).offset(16);
    //        make.right.equalTo(baseView.mas_right).offset(-10);
    //        make.height.mas_equalTo(20);
    //    }];
    //
    
    
}



-(void)setDataSource:(MCMySubDaywagesNewDataModel *)dataSource{
    _dataSource=dataSource;
    
    if (dataSource.MyInfoList.count>0) {
        
        MCGetSubDaywagesNewDataContractListModel * model1 = dataSource.MyInfoList[0];
        
        _DayWagesProportion.text = [NSString stringWithFormat:@"我的日结契约：【%@】",[MCContractMgtTool GetPercentNumber:model1.MyProportion andStatisticModeCode:_dataSource.StatisticModeCode]];
        
    }
    
    
    if (_xiaJiModel && dataSource) {
        
        if (dataSource.SubInfoList.count>0) {
            MCGetSubDaywagesNewDataContractListModel * model2 = dataSource.SubInfoList[0];
            //            _UserName.text = [NSString stringWithFormat:@"用户名：%@",_xiaJiModel.UserName];
            _UserName.text = [NSString stringWithFormat:@"下级【%@】日结契约：%@ ",_xiaJiModel.UserName,[MCContractMgtTool GetPercentNumber:model2.MyProportion andStatisticModeCode:_dataSource.StatisticModeCode]];
            
            //            _Wage.text=[NSString stringWithFormat:@"当前日结：【%@】的日结",[MCContractMgtTool GetPercentNumber:model2.MyProportion andStatisticModeCode:_dataSource.StatisticModeCode]];
            
        }else{
            
            _UserName.text = [NSString stringWithFormat:@"下级【%@】日结契约：无 ",_xiaJiModel.UserName];
            //            _Wage.text=@"当前日结：0";
        }
        
    }
    
}

-(void)setXiaJiModel:(MCGetSubDaywagesNewDataContractListModel *)xiaJiModel{
    
    _xiaJiModel=xiaJiModel;
    if (_xiaJiModel && _dataSource) {
        if (_dataSource.SubInfoList.count>0) {
            
            MCGetSubDaywagesNewDataContractListModel * model2 = _dataSource.SubInfoList[0];
            
            //            _UserName.text = [NSString stringWithFormat:@"用户名：%@",_xiaJiModel.UserName];
            
            _UserName.text = [NSString stringWithFormat:@"下级【%@】日结契约：%@ ",_xiaJiModel.UserName,[MCContractMgtTool GetPercentNumber:model2.MyProportion andStatisticModeCode:_dataSource.StatisticModeCode]];
            
            //            _Wage.text=[NSString stringWithFormat:@"当前日结：【%@】的日结",[MCContractMgtTool GetPercentNumber:model2.MyProportion andStatisticModeCode:_dataSource.StatisticModeCode]];
            
        }else{
            
            //            _UserName.text = [NSString stringWithFormat:@"用户名：%@",_xiaJiModel.UserName];
            
            _UserName.text = [NSString stringWithFormat:@"下级【%@】日结契约：无 ",_xiaJiModel.UserName];
            
            //            _Wage.text=@"当前日结：0";
        }
        
    }
}


+(CGFloat)computeHeight:(id)info{
    //    return 71+15+10 +30;
    return 71+15+10;
}


@end

